925. 长按键入
为保证权益,题目请参考 925. 长按键入(From LeetCode).
解决方案1
Python
python
class Solution:
def isLongPressedName(self, name: str, typed: str) -> bool:
l = 0
for x in typed:
if l < (n := len(name)):
if x == name[l]:
l += 1
elif l - 1 >= 0 and x == name[l - 1]:
pass
else:
return False
else:
if x != name[l - 1]:
return False
return l == len(name)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15